﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FoundationLib.Common.Extensions;

namespace FoundationLib.Common.Calendar
{
	/// <summary>
	/// Provides a default implementation of a week of year formatter.
	/// </summary>
	public class DefaultWeekOfYearFormatter : WeekOfYearFormatter
	{
		/// <see cref="WeekOfYearFormatter.Format(WeekOfYear)"/>
		public override string Format(WeekOfYear value)
		{
			WeekOfYear current = WeekOfYear.ThisWeek;
			double distance = value - current;
			if (distance == 0.0)
			{
				return "This Week";
			}
			else if (distance > 0.0)
			{
				if (distance == 1.0)
					return "Next Week";
				else
					return "In {0} Weeks".FormatWith((int)distance);
			}
			else if (distance < 0.0)
			{
				if (distance == -1.0)
					return "Last Week";
				else
					return "{0} Weeks Ago".FormatWith((int)distance * (-1));
			}
			else
			{
				return "Week {0}".FormatWith(value.ToString());
			}
		}
	}
}
